#include "../head/mainHead.h"

// 主菜单
void mainMenuPrint(char* selec){
    printf("+-----------------------------------------------------+\n");
    printf("|-------------进---程---调---度---算---法-------------|\n");
    printf("+-+------------------------+-+------------------------+\n");
    printf("|-|----非**抢**占**式------|-|------抢**占**式--------|\n");
    printf("+-+------------------------+-+------------------------+\n");
    printf("|1|----先来先服务(FCFS)----|5|--抢占式高优先级(PHPF)--|\n");
    printf("+-+------------------------+-+------------------------+\n");
    printf("|2|---最短作业优先(SJF)----|6|------------------------|\n");
    printf("+-+------------------------+-+------------------------+\n");
    printf("|3|--最高响应比优先(HRRF)--|7|------------------------|\n");
    printf("+-+------------------------+-+------------------------+\n");
    printf("|4|----优先级调度(HPF)-----|8|------进程基本操作------|\n");
    printf("+-+------------------------+-+------------------------+\n");
    printf("|0|--------------------结-------束--------------------|\n");
    printf("+-+---------------------------------------------------+\n");
    printf("|期待您的选择-> ");
    scanf("%c", selec);
}

// 退出时显示
void mainMenuBye(){
    printf("+-----------------------------------------------------+\n");
    printf("+-----------------------------------------------------+\n");
    printf("+-----------------------------------------------------+\n");
    printf("|----------感---谢---您---的---使---用---!!!----------|\n"); 
    printf("|----------欢---迎---下---次---光---临---!!!----------|\n"); 
    printf("+-----------------------------------------------------+\n");
    printf("+-----------------------------------------------------+\n");
    printf("+-----------------------------------------------------+\n");
    system("pause");
}

// 进程操作选择
void processOptMenu(char* processOptNum){
    printf("+-----------------------------------------------------+\n");    
    printf("|--------------进--程--操--作--选--择-----------------|\n");    
    printf("+--------------+-+------------------+-----------------+\n");    
    printf("|--------------|1|-----批量输入-----|-----------------|\n");    
    printf("+--------------+-+------------------+-----------------+\n");    
    printf("|--------------|2|-----单个输入-----|-----------------|\n");    
    printf("+--------------+-+------------------+-----------------+\n");    
    printf("|--------------|3|-----单个修改-----|-----------------|\n");   
    printf("+--------------+-+------------------+-----------------+\n");
    printf("|--------------|4|-----批量输出-----|-----------------|\n");
    printf("+--------------+-+------------------+-----------------+\n");    
    printf("|--------------|5|-----单个输出-----|-----------------|\n");
    printf("+--------------+-+------------------+-----------------+\n");    
    printf("|--------------|0|-----返----回-----|-----------------|\n"); 
    printf("+--------------+-+------------------+-----------------+\n");  
    printf("+-----------------------------------------------------+\n");     
    printf("|期待您的选择-> ");
    scanf("%c",processOptNum);
}

// 选择操作的进程
void processNumSeleMenu(char* processNumSele){
    printf("+-----------------------------------------------------+\n");
    printf("|----------------进----程----选----择-----------------|\n");
    printf("+-----------------+-+--------------+------------------+\n");
    printf("|-----------------|1|---进程--一---|------------------|\n");
    printf("+-----------------+-+--------------+------------------+\n");
    printf("|-----------------|2|---进程--二---|------------------|\n");
    printf("+-----------------+-+--------------+------------------+\n");
    printf("|-----------------|3|---进程--三---|------------------|\n");
    printf("+-----------------+-+--------------+------------------+\n");
    printf("|-----------------|4|---进程--四---|------------------|\n");
    printf("+-----------------+-+--------------+------------------+\n");
    printf("|-----------------|0|---返----回---|------------------|\n");
    printf("+-----------------+-+--------------+------------------+\n");
    printf("+-----------------------------------------------------+\n");
    printf("|期待您的选择-> ");
    scanf("%c",processNumSele);
}

// 选择需要修改的属性
void processAltNumSeleMenu(char* processAltNum){
    printf("+-----------------------------------------------------+\n");  
    printf("|----------------进--程--属--性--选--择---------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|1|-----进程名-----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");  
    printf("|-----------------|2|--进程到达时间--|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");  
    printf("|-----------------|3|--进程运行时间--|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");  
    printf("|-----------------|4|---进程优先级---|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");  
    printf("|-----------------|0|---返------回---|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");  
    printf("+-----------------------------------------------------+\n");  
    printf("|期待您的选择-> ");
    scanf("%c",processAltNum);
}

// 输出所有进程信息
void processPrintAll(){
    system("cls");
    printf("+-----------------------------------------------------+\n");  
    printf("|----------------进--程--属--性--输--出---------------|\n");  
    for(int i = 1; i < 5; i++){
        printf("+-----------------------------------------------------+\n");
        printf("|-----------第%d个进程---------------------------------|\n",i);
        printf("|---进程的名称-> %s\n",p[i].PNAME);
        printf("|---进程的进程号-> %d\n",p[i].PID);
        printf("|---进程到达时间-> %s\n",p[i].Ta);
        printf("|---进程开始时间-> %s\n",p[i].Ts);
        printf("|---进程运行时间-> %d(min)\n",p[i].Tr);
        printf("|---进程结束时间-> %s\n",p[i].Tf);
        printf("|---进程周转时间-> %d(min)\n",p[i].Tar);
        printf("|---带权周转时间-> %.2lf\n",p[i].TTWA);
        printf("|---进程的优先级-> %d\n",p[i].Priority);
        printf("+-----------------------------------------------------+\n");
        Sleep(1000);
    }
    system("pause");
}

// 输出进程执行先后顺序
void exeOrderPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|--------进---程---执---行---先---后---顺---序--------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程 %d\n",exeQueue[i]);
        if(i != 4){
            printf("       ↓\n");
        }
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// 输出进程号
void pidPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---的---进---程---号-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %d\n",i,p[i].PID);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");        
}

// 输出进程到达时间
void pnamePrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进----程----的----名----字--------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %s\n",i,p[i].PNAME);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// 输出进程到达时间
void taPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---到---达---时---间-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %s\n",i,p[i].Ta);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// arrived[],换算成分钟
void processArrivePrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---到---达---时---间-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|---进程%d-> %d (min)\n",i,arriveTime[i]);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");
}

// 输出进程开始时间
void tsPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---开---始---时---间-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %s\n",i,p[i].Ts);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// 输出进程运行时间
void trPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---运---行---时---间-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %d\n",i,p[i].Tr);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// 输出进程结束时间
void tfPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---结---束---时---间-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %s\n",i,p[i].Tf);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// 输出进程周转时间
void cycleTime(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|---------进---程---周---转---时---间---(min)---------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %d\n",i,p[i].Tar);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");
}

// 输出带权周转时间
void cycleTimeWithRight(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------带---权---周---转---时---间-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %.2lf\n",i,p[i].TTWA);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");       
}

// 输出进程优先级
void priorityPrint(){
    printf("+-----------------------------------------------------+\n"); 
    printf("|-------------进---程---的---优---先---级-------------|\n"); 
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        printf("|--->进程%d: %d\n",i,p[i].Priority);
    }
    printf("+-----------------------------------------------------+\n");
    system("pause");
}

// 输出平均周转时间
void avgCycleTime(){ 
    double avgCT = 0;
    printf("+-----------------------------------------------------+\n");
    for(int i = 1; i < 5; i++){
        avgCT += p[i].Tar;
    }
    printf("|--->平均周转时间: %.2lf(min)\n", (avgCT / 4));
    printf("+-----------------------------------------------------+\n");
    system("pause");    
}

// 输出平均带权周转时间
void avgCycleTimeWithRight(){
    double avgCTWR = 0;
    printf("+-----------------------------------------------------+\n"); 
    for(int i = 1; i < 5; i++){
        avgCTWR += p[i].TTWA;
    }
    printf("|--->平均带权周转时间: %.2lf\n", (avgCTWR / 4));
    printf("+-----------------------------------------------------+\n");
    system("pause");       
}

// 进程属性输出
void attriPrintSingleMenu(char* attriPrintSingleNUm){
    system("cls");
    printf("+-----------------------------------------------------+\n");
    printf("|----------------进--程--属--性--输--出---------------|\n");
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|1|----进-程-号----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|2|----进-程-名----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|3|----到达时间----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|4|----开始时间----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|5|----运行时间----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|6|----结束时间----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|7|----周转时间----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|8|--带权周转时间--|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|9|----优-先-级----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");
    printf("|-----------------|0|----返----回----|----------------|\n");  
    printf("+-----------------+-+----------------+----------------+\n");  
    printf("+-----------------------------------------------------+\n");  
    printf("|期待您的选择-> ");
    scanf("%c",attriPrintSingleNUm);
}
